<template>
  <div>
    <el-card align="right" style="margin-top: 15px" class="top-card">
      <el-button type="primary">打印</el-button>
    </el-card>

    <el-card style="margin-top: 25px">
      <div class="box">
        <div class="title" align="center">员工信息</div>
        <div class="header">
          <el-descriptions :column="2" border>
            <el-descriptions-item label="姓名">{{
              userDetail.username
            }}</el-descriptions-item>
            <el-descriptions-item label="性别">{{
              userDetail.gender
            }}</el-descriptions-item>
            <el-descriptions-item label="民族">{{
              userDetail.nationality
            }}</el-descriptions-item>
            <el-descriptions-item label="手机号">{{
              userDetail.mobile
            }}</el-descriptions-item>
            <el-descriptions-item label="居住地"></el-descriptions-item>
            <el-descriptions-item label="入职时间">
              {{ parseInt(userDetail.openTime) | getTime }}
            </el-descriptions-item>
            <el-descriptions-item label="备注" :span="2">
              <template>
                <el-tag
                  style="margin: 0px 5px"
                  v-for="(item, index) in userDetail.remark"
                  :key="index"
                >
                  {{ item }}
                </el-tag>
              </template>
            </el-descriptions-item>
            <el-descriptions-item label="联系地址" :span="2">{{
              userDetail.address
            }}</el-descriptions-item>
          </el-descriptions>
          <el-image
            class="avatar"
            :src="userDetail.avatar"
            :preview-src-list="[userDetail.avatar]"
          ></el-image>
        </div>
        <div class="body">
          <el-descriptions direction="vertical" :column="3" border>
            <el-descriptions-item label="经历" :span="3">
              <ul class="list">
                <li v-for="(item, index) in userDetail.experience" :key="index">
                  <span>{{ parseInt(item.startTime) | moment }}</span>
                  ----
                  <span>{{ parseInt(item.endTime) | moment }}</span>
                  <span>{{ item.title }}</span>
                  <span>{{ item.desc }}</span>
                </li>
              </ul>
            </el-descriptions-item>
            <el-descriptions-item label="专业" :span="3">{{
              userDetail.major
            }}</el-descriptions-item>
            <el-descriptions-item label="荣耀" :span="3">{{
              userDetail.glory
            }}</el-descriptions-item>
          </el-descriptions>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
import moment from "moment";
import userApi from "../../api/sys";
export default {
  data() {
    return {
      id: this.$route.params.id,
      userDetail: {},
    };
  },
  mounted() {
    // console.log(this.id);
    this.getUserDetail();
  },
  filters: {
    getTime(date) {
      return moment(date).format("YYYY-MM-DD");
    },
    moment(date) {
      return moment(date).format("YYYY/MM");
    },
  },
  methods: {
    async getUserDetail() {
      let res = await userApi.getUserDetail(this.id);
      this.userDetail = res;
      console.log(this.userDetail);
    },
  },
};
</script>

<style scoped lang='scss'>
.box {
  width: 1024px;
  margin: 0 auto;
  .title {
    font-size: 25px;
    font-weight: bold;
    margin-bottom: 10px;
  }
  .header {
    display: flex;
    ::v-deep .el-descriptions {
      flex-grow: 1;
    }
    .avatar {
      width: 187px;
      box-sizing: border-box;
      padding: 30px 20px;
      border: 1px solid #ebeef5;
      border-left: none;
    }
  }
  .body {
    .list {
      list-style: none;
      span {
        margin: 0 10px;
        display: inline-block;
      }
    }
  }
}
</style>
